package com.bs.bookshare.controller;


import com.bs.bookshare.Mapper.RecomMapper;
import com.bs.bookshare.common.Resp;
import com.bs.bookshare.request.requestRecom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RecomAction {

    @Autowired
    private RecomMapper recomMapper;

    @PostMapping("/shareRecommon")
    public Resp getRecom(@RequestBody requestRecom recom) {
        if(recomMapper.setRecom(recom.getUserid(),recom.getBookid(),recom.getRecommondation()) == 1){
            return Resp.notok().data("info","sumitSuccess");
        }
        return Resp.notok().data("info","sumitFail");
    }


    @PostMapping("/getRecomList")
    public Resp getRecomList() {
        return Resp.notok().data("info",recomMapper.getRecomList());
    }

    @PostMapping("/getReviewsNumber")
    public Resp getReviewsNumber() {
        int recom = recomMapper.getReviews();
        return Resp.notok().data("info",recom);
    }

}
